package com.shuimo.emoswxapi.wx.common.enums;

public enum GlobalStatusEnum {

    SUCCESS(200, "成功"),
    AUTHORITY_ERROR(401, "鉴权失败"),
    ERROR(500, "系统错误"),



    PARAM_EXCEPTION(1000, "参数异常"),
    INVALID_TOKEN(10001, "无效的token"),
    TEMP_CODE_ERROR(10002, "临时登录凭证code异常"),
    ADMIN_EXIST(10003, "管理员已经存在"),


    TEST_ERROR(9999, "测试异常"),

    ;


    /**
     * code码
     */
    private int code;
    /**
     * 消息值
     */
    private String msg;

    private GlobalStatusEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static GlobalStatusEnum getEnum(int code) {
        GlobalStatusEnum[] values = GlobalStatusEnum.values();
        for (GlobalStatusEnum codeEnum : values) {
            if (codeEnum.getCode() == code) {
                return codeEnum;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
